/**
 * Project Name:template-web
 * File Name   :GenderEnum.java
 * Package Name:org.cn.template.component.enums
 * Date:2015年9月27日下午4:21:42
 * Copyright (c) 2015, http://my.oschina.net/httpssl All Rights Reserved.
 *
*/

package org.cn.template.component.enums;

/**
 * ClassName:GenderEnum <br/>
 * Function :TODO ADD FUNCTION. <br/>
 * Reason	:TODO ADD REASON. <br/>
 * Date     :2015年9月27日 下午4:21:42 <br/>
 * @author  :http://my.oschina.net/httpssl
 * @email   :491835898@QQ.COM
 * @since   :JDK 1.7
 * @see 	 
 */
public enum GenderEnum
{
	male(1, "男"),
	female(0, "女"),
	defaults(2, "保密");
	
	private int code;
	private String label;
	
	private GenderEnum(int code, String label) {
		this.code = code;
		this.label = label;
	}
	
	public static GenderEnum parse(Integer code){
		if(code == null){
			return GenderEnum.defaults;
		}
		for (GenderEnum gender : GenderEnum.values()) {
			if(gender.getCode() == code.intValue()){
				return gender;
			}
		}
		return null;
	}
	
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getLabel() {
		return label;
	}
	public void setLabel(String label) {
		this.label = label;
	}
}
